package com.ncmmall.domain.business.goods.channel;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;

/**
 * @author linxs
 * @Description: 商品类目
 * @Date: 2019-06-27 22:07
 */
@Entity
@Table(name = "mall_goods_channel")
@Access(AccessType.FIELD)
@Setter
@Getter
public class GoodsChannel {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    /**
     * 类目名称
     */
    private String name;

    /**
     * 类目等级
     * 1、一级类目
     * 2、二级类目
     * 3、三级类目
     */
    private int level;

    /**
     * 类目图标
     */
    private String icon;

    /**
     * 父类目
     */
    @JsonIgnore
    @ManyToOne
    @JoinColumn(name = "parent")
    @NotFound(action = NotFoundAction.IGNORE)
    private GoodsChannel parent;

    /**
     * 子类目
     */
    @OneToMany(fetch = FetchType.EAGER)
    @JoinColumn(name = "parent")
    private List<GoodsChannel> children;

    /**
     * 1、启用
     * 2、禁用
     */
    private int status;

    /**
     * 1、逻辑删除
     */
    private int deleteStatus;

    /**
     * 推荐首页
     * true、推荐
     */
    private boolean recommend;

    /**
     * 推荐到采购端首页
     * true、推荐
     */
    private boolean supplierRecommend;

    /**
     * 创建时间
     */
    private Timestamp createTime;

}
